<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{$Think.lang.contentlst}</title>
    <link rel="stylesheet" href="__ADMIN__/vendor/layui/css/layui.css">
    <link rel="stylesheet" href="__ADMIN__/custom/css/style.css">
</head>
<body style="padding:10px 10px;">
<form class="layui-form" action="{:url('article/delall')}" method="post">
<div>
    <a href="{:url('article/add')}" class="layui-btn layui-btn-normal">{$Think.lang.contentadd}</a>
    <button type="submit" class="layui-btn layui-btn-danger">{$Think.lang.delall}</button>
    <div class="layui-form-item" style="float: right;">
        <label class="layui-form-label">{$Think.lang.selectdepID}</label>
        <div class="layui-input-inline">
            <select name="cid" lay-filter="lanmu">
                <option value="">{$Think.lang.showall}</option>
                {volist name="cate" id="vo"}
                <option value="{$vo.id}" {eq name="vo.id" value="$cid"}selected{/eq}>{$vo.name}</option>
                {/volist}
            </select>
        </div>
    </div>
<table class="layui-table" lay-size="md">
    <colgroup>
        <col width="60">
        <col width="80">
        <col>
        <col width="100">
        <col width="170">
        <col width="100">
        <col width="100">
        <col width="100">
        <col width="220">
    </colgroup>
    <thead>
    <tr style="height: 45px" pid="0">
        <th style="text-align:center;"><input type="checkbox" name="" lay-skin="primary" lay-filter="quanxuan"></th>
        <th style="text-align: center;">ID</th>
        <th>{$Think.lang.title}</th>
        <th>{$Think.lang.depID}</th>
        <th>{$Think.lang.addtime}</th>
        <th style="text-align: center;">{$Think.lang.views}</th>
        <th style="text-align: center;">{$Think.lang.Thum}</th>
        <th style="text-align: center;">{$Think.lang.top}</th>
        <th>{$Think.lang.handle}</th>
    </tr>
    </thead>
    <tbody>

    {volist name="list" id="vo"}
    <tr>
        <td style="text-align: center;"><input type="checkbox" name="id[]" class="qx" lay-skin="primary" value="{$vo.id}"></td>
        <td style="text-align: center;">{$vo.id}</td>
        <td>{$vo.title}</td>
        <td>{$vo.name}</td>
        <td>{$vo.addtime|date="Y/m/d H:i:s",###}</td>
        <td style="text-align: center;">{$vo.views}</td>
        <td style="text-align: center;">{if condition="$vo.pic eq 0"}{$Think.lang.picnone}{else}{$Think.lang.pics} <span class="layui-badge">{$vo.pic}</span>{$Think.lang.copies}{/if}</td>
        <td style="text-align: center;"><input type="checkbox" name="istop" lay-filter="istop" lay-skin="switch" lay-text="{$Think.lang.toptip}" value="{$vo.id}" {$vo.istop?"checked":""}></td>
        <td>
            <botton class="layui-btn layui-btn-mini {eq name="vo.pic" value="0"}layui-btn-disabled{/eq} tupian" id="{$vo.id}"><i class="layui-icon">&#xe64a;</i>{$Think.lang.pic}</botton>
            <a href="{:url('article/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-warm layui-btn-mini"><i class="layui-icon">&#xe642;</i>{$Think.lang.edit}</a>
            <a href="{:url('article/del',['aid'=>$vo.id])}" class="layui-btn layui-btn-danger layui-btn-mini del"><i class="layui-icon">&#xe640;</i>{$Think.lang.delete}</a>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
    <div style="text-align: right;">{$list->render()}</div>
</div>
</form>

<script src="__ADMIN__/vendor/js/jquery.js"></script>
<script src="__ADMIN__/vendor/layui/layui.js"></script>
<script src="__ADMIN__/custom/js/admin.js"></script>
<script>
    layui.use(['layer','form'], function(){
        var layer = layui.layer;
        var form = layui.form;

        $('.del').on('click',function () {
            var url=$(this).attr('href');
            layer.confirm('{$Think.lang.suredel}?', {icon: 3, title:'{$Think.lang.tishi}'}, function(index){
                //do something
                location.href=url;
                layer.close(index);
            });
            return false;
        });
        //监听栏目
        form.on('select(lanmu)', function(data){
            var cid=data.value;
            location.href="{:url('admin/article/index')}?cid="+cid;
        });
        form.on('switch(istop)', function(data){
            var istop=data.elem.checked;
            var id=data.value;
            $.ajax({
                'type':'post',
                'url':"{:url('admin/article/istop')}",
                'data':{'id':id,'istop':istop},
                'datatype':'json',
                success:function (msg) {
                    layer.msg(msg.msg,{time:1000},function () {
                        location.href="{:url('admin/article/index')}";
                    });
                }
            });
        });
        //全选与取消
        form.on('checkbox(quanxuan)', function(data){
            if(data.elem.checked){
                //全选
                //$('.qx').prop('checked','checked');
                $('.qx').prop('checked',true);
                form.render();
            }else{
                //取消全选
                //$('.qx').removeAttr('checked');
                $('.qx').prop('checked',false);
                form.render();
            }
        });
        //图片按钮点击事件
        $('.tupian').on('click',function () {
            var aid=$(this).attr("id");
            if($(this).hasClass('layui-btn-disabled')){
                return false;
            }
            layer.open({
                type: 2,
                title:'{$Think.lang.pic}',
                area: ['700px', '450px'],
                fixed: false, //不固定
                maxmin: true,
                content: '{:url("admin/article/pics")}?aid='+aid
            });
        });
    });

    $(function(){
        $(window.parent.document).find('#righttitle').text($('title').text());
   });
</script>
</body>
</html>